package org.chen.admin.web.controller.system;


import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.chen.admin.web.service.LoginService;
import org.chen.common.core.domain.AjaxResult;
import org.chen.common.dto.LoginBody;
import org.chen.common.dto.LoginResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;


@Tag(name = "登录")
@Slf4j
@RestController
public class LoginController {

    @Autowired
    private LoginService loginService;


    @PostMapping("/login")
    @Operation(summary = "用户登录")
    @ApiResponses(
            {
                    @ApiResponse(
                            responseCode = "200",
                            description = "登录成功",
                            content = @Content(
                                    mediaType = "application/json",
                                    schema = @Schema(implementation = LoginResponse.class)
                            )
                    )
            }
    )
    public AjaxResult login(@RequestBody LoginBody loginBody) {
        log.info("登录");
        return loginService.login(loginBody);

    }
}
